package com.ksm.zyz.common.util;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Properties;

public class Test {

	public static void main(String[] args) {
		String ip = "192.11.1:33066";
		String date="dmy.cc";
		//String path=request.getSession().getServletContext().getRealPath("");
		String p=System.getProperty("user.dir");
		//String p=path;
		System.out.println(p+"@@@@@");
		Properties prop = new Properties();     
        try{
           //读取属性文件a.properties
            InputStream in = new BufferedInputStream (new FileInputStream(p+"/dmy-sync/WEB-INF/classes/jdbc.properties"));
            prop.load(in);     ///加载属性列表
            Iterator<String> it=prop.stringPropertyNames().iterator();
            prop.setProperty("jdbc1.url", "jdbc:sqlserver://"+ip+";DatabaseName="+date);           
            while(it.hasNext()){
                String key=it.next();
                System.out.println(key+":"+prop.getProperty(key));
            }
            in.close();
            
           ///保存属性到b.properties文件
            FileOutputStream oFile = new FileOutputStream(p+"/dmy-sync/WEB-INF/classes/jdbc.properties", false);//true表示追加打开
            prop.store(oFile, "The New properties file");
            oFile.close();
        }
        catch(Exception e){
            System.out.println(e);
        }
	}



}
